#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSerialPort>        //提供访问串口的功能
#include <QSerialPortInfo>    //提供系统中存在的串口的信息

#include <QFile> //文件对象
#include <QFileDialog>  //文件路径
#include <QFileInfo>  //文件信息
#include <QTimer>

#include <QDebug>
#define cout qDebug() << "[" << __FILE__":" << __LINE__ << "]"
#define VERSION  "1.0"
namespace Ui {
class MainWindow;
}
#include "audioplaythread.h"

typedef struct main
{
    uint8_t updateflg;
    uint8_t version[4];
    uint32_t size;
    uint8_t date[64];
}version_t;
//}__attribute__((packed)) version_t;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    AudioPlayThread aud;
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void senddata(char *data, qint64 len);
private slots:
    void serialPort_readyRead();

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_clicked();

private:
    Ui::MainWindow *ui;

    QSerialPort serial;
    QFile file;
    QString filename;
    qint64 filesize;
    qint64 sendSize;
    volatile bool ready_send = true;
    QString path;
    qint64 len = 0;
};

#endif // MAINWINDOW_H
